package 作业2;

public class ChickenRabbitProblem {
    public static void main (String[] args){
        int totalHeads=40;
        int totalLegs=100;

        for(int chickens =0;chickens<=totalHeads;chickens++){
            int rabbits=totalHeads -chickens;

            int calculatedLegs=(chickens*2)+(rabbits*4);

            if(calculatedLegs == totalLegs){
                System.out.println("鸡的数量"+chickens);
                System.out.println("兔子的数量："+rabbits);
                break;
            }
        }
    }
}
